//inicializamos el system
system_lib = {};

(function () {

    var droppler = {
        scripts: [
            'config.js',
            //trunk > 
            'libs/classes.js',
            'libs/debug.js',
            'libs/system.js',
            'libs/tuenti.js',
            'modules/config.js',
            'modules/themes.js',
            'modules/background.js',
            'modules/ads.js',
            'modules/avatar.js',
            'modules/bbcode.js',
            'modules/invite.js',
            'modules/updater.js',
            'modules/enchancer.js',
            'modules/ghostimage.js',
            'modules/preview.js',
            'modules/stats.js'
        ],
        id: 'droppler',
        init: function() {

            //Tomamos la baseUrl del src
            system_lib.baseUrl = /^(http:\/\/.*?\/)[a-z0-9]*.js$/ig.exec(document.getElementById(this.id).src)[1];

            //punto de inseccion la etiqueda head
            var head = document.getElementsByTagName('head')[0];

            //iteramos e injectamos
            for (var i = 0; i < this.scripts.length; i++) {
                this.loadScript(this.scripts[i], head);
            }
        },
        loadScript: function(url, head) {
            var script = document.createElement('script');
            script.type = 'text/javascript';
            script.src = system_lib.baseUrl + url;
            head.appendChild(script);
        }
    };

    droppler.init();
})();